Option Strict On
Option Explicit On

Imports System

Public Interface IMapJoin
   ReadOnly Property MapMappingRoot() As MapMappingRoot
   Property Name() As System.String
   Property [Alias]() As System.String
   Property LeftAlias() As System.String
   Property TableName() As System.String
   Property JoinTo() As System.String
   Property JoinToColumn() As System.String
   Property JoinType() As System.String
   Property Clause() As System.String
   Property NoColumns() As Nullable(Of Boolean)
   Property LeftOriginalName() As System.String
   Property RightOriginalName() As System.String
   'ReadOnly Property MapJoinIns() As MapJoinInCollection
   ReadOnly Property MapJoinInColumns() As MapJoinInColumnCollection
   ReadOnly Property MapJoinKeys() As MapJoinKeyCollection
End Interface

Public Interface IMapJoinCollection
   Inherits IEnumerable(Of IMapJoin)
   ReadOnly Property Count() As Int32
   Default ReadOnly Property Item(ByVal position As Int32) As IMapJoin
   Default ReadOnly Property Item(ByVal joinName As String) As IMapJoin
   Function GetByTableName(ByVal rightTableName As String) As IMapJoin
End Interface

Public Class MapJoinEnumerator
   Implements IEnumerator(Of IMapJoin)

   Public joins As IMapJoinCollection

   ' Enumerators are positioned before the first element
   ' until the first MoveNext() call.
   Dim position As Int32 = -1

   Public Sub New(ByVal joins As IMapJoinCollection)
      Me.joins = joins
   End Sub

   Private Function MoveNext() As Boolean Implements IEnumerator.MoveNext
      position = position + 1
      Return (position < joins.Count)
   End Function

   Private Sub Reset() Implements IEnumerator.Reset
      position = -1
   End Sub

   Private ReadOnly Property Current() _
            As IMapJoin _
            Implements IEnumerator(Of KadGen.MetadataWrapper.IMapJoin).Current
      Get
         If position >= 0 And position < joins.Count Then
            Return joins(position)
         End If
         Throw New InvalidOperationException()
      End Get
   End Property

   Private ReadOnly Property Current1() _
            As Object _
            Implements IEnumerator.Current
      Get
         Return Current()
      End Get
   End Property

#Region " IDisposable Support "
   Private disposedValue As Boolean = False      ' To detect redundant calls

   ' IDisposable
   Protected Overridable Sub Dispose(ByVal disposing As Boolean)
      If Not Me.disposedValue Then
         If disposing Then
            ' No unmanaged resources to free
         End If

         If joins IsNot Nothing Then
            joins = Nothing
         End If
      End If
      Me.disposedValue = True
   End Sub

   ' This code added by Visual Basic to correctly implement the disposable pattern.
   Public Sub Dispose() Implements IDisposable.Dispose
      ' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
      Dispose(True)
      GC.SuppressFinalize(Me)
   End Sub
#End Region

End Class


